﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using GuessTheWordsEditor.Model;

namespace GuessTheWordsEditor
{
    /// <summary>
    /// Interaction logic for WordEditorWindow.xaml
    /// </summary>
    public partial class WordEditorWindow : Window
    {
        public WordInfoModel WordModel { get; set; }

        public WordEditorWindow()
        {
            this.InitializeComponent();
            this.Topmost = true;
            this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            this.Loaded += new RoutedEventHandler(WordEditorWindow_Loaded);
        }

        void WordEditorWindow_Loaded(object sender, RoutedEventArgs e)
        {
            this.Loaded -= new RoutedEventHandler(WordEditorWindow_Loaded);

            this.btnOK.Click += new RoutedEventHandler(btnOK_Click);
            this.btnCancle.Click += new RoutedEventHandler(btnCancle_Click);
        }

        void btnCancle_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
            this.Close();
        }

        void btnOK_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(txtResult.Text.Trim())
                || String.IsNullOrEmpty(txtPY.Text.Trim())
                || String.IsNullOrEmpty(txtDes.Text.Trim()))
            {
                MessageBox.Show("请填写完整数据再次提交!", "77Studio");
                return;
            }
            this.DialogResult = true;
            WordModel = new WordInfoModel();
            WordModel.Result = txtResult.Text.Trim();
            WordModel.Pinyin = txtPY.Text.Trim();
            WordModel.Describe = txtDes.Text.Trim();
            this.Close();
        }


    }
}